package point

import (
	"dev_gw/common"
	"fmt"

	"github.com/spf13/viper"
)

type Rs485CountPoint struct{}

func NewRs485CountPoint() *Rs485CountPoint { return &Rs485CountPoint{} }

func (s *Rs485CountPoint) Get() any {
	v := viper.New()
	v.SetConfigName("config")
	v.SetConfigType("yaml")
	v.AddConfigPath(common.ConfigFilePath)
	err := v.ReadInConfig()
	if err != nil {
		fmt.Println("read config file failed, err -->", err)
		return 0
	}

	ports := v.GetStringSlice("rs485Ports")
	return len(ports)

}

func (s *Rs485CountPoint) Set(...any) bool { return false }

func (s *Rs485CountPoint) SetRoute(string) PointInterface { return s }
